<template>
  <div class="app" >
    <tabbar ref="reflectName" tabSlideSwitch="false"  iconWidth=120 iconHeight=50 iconMargin='5' textSelectColor="red" class="tabbar" :tabPages="tabPages"
            @pageSelected='pageSelected' @tabSelect='tabSelect'>
    </tabbar>

    <div class="privacyBox" @click=""  v-if="privacyType == true" >
      <div class="privacyContent">
        <text class="privacy_headerTitle">个人信息保护声明</text>
        <text class="privacy_title" style="margin-top:30px">        保护用户个人信息是{{companyName}}的一项基本原则。</text>
        <text class="privacy_title" style="margin-top:30px">        我们将按照《用户协议》和《隐私政策》的规定收集、使用、存储和分享您的个人信息</text>
        <text class="privacy_title" style="margin-top:30px">        您点击“同意”，即表示您已阅读并同意上述条款，{{companyName}}将尽力保障您的合法权益并继续为您提供优质的产品和服务。如果您点击“不同意”，将可能导致您无法使用我们的产品和服务</text>
        <div style="display:flex;flex-direction: row;flex-wrap:wrap;margin-top:30px;padding-left:30px;padding-right:30px">
          <text style="font-size: 30px;color: #999999;">        您可通过</text>
          <text style="font-size: 30px;color: #999999;">可</text>
          <text style="font-size: 30px;color: #999999;">通</text>
          <text style="font-size: 30px;color: #999999;">过</text>
          <text style="font-size:32px;color:#333333">《</text>
          <text style="font-size:32px;color:#333333" @click="userAgreement">用</text>
          <text style="font-size:32px;color:#333333" @click="userAgreement">户</text>
          <text style="font-size:32px;color:#333333" @click="userAgreement">协</text>
          <text style="font-size:32px;color:#333333" @click="userAgreement">议</text>
          <text style="font-size:32px;color:#333333">》</text>
          <text style="font-size:32px;color:#333333">和</text>
          <text style="font-size:32px;color:#333333">《</text>
          <text style="font-size:32px;color:#333333" @click="privacyClick">隐</text>
          <text style="font-size:32px;color:#333333" @click="privacyClick">私</text>
          <text style="font-size:32px;color:#333333" @click="privacyClick">政</text>
          <text style="font-size:32px;color:#333333" @click="privacyClick">策</text>
          <text style="font-size:32px;color:#333333">》</text>
          <text style="font-size: 30px;color: #999999;">查</text>
          <text style="font-size: 30px;color: #999999;">阅</text>
          <text style="font-size: 30px;color: #999999;">完</text>
          <text style="font-size: 30px;color: #999999;">整</text>
          <text style="font-size: 30px;color: #999999;">的</text>
          <text style="font-size: 30px;color: #999999;">协</text>
          <text style="font-size: 30px;color: #999999;">议</text>
          <text style="font-size: 30px;color: #999999;">内</text>
          <text style="font-size: 30px;color: #999999;">容</text>
        </div>
        <div class="privacy_botton">
          <div class="privacy_botton_left" @click="disagreeClick">
            <text class="privacy_botton_left_title">不同意</text>
          </div>
          <div class="privacy_botton_right" @click='agreeClick'>
            <text class="privacy_botton_right_ittle">同意并继续</text>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {
  list,
  find
} from '../api/wxPage'

const eeui = app.requireModule("eeui");
const picker = app.requireModule("picker");
const storage = weex.requireModule('storage')
import login from "./login/msgLogin";
import myOrder from "../components/myOrder/myOrder";
import {
  sendMsg
} from "../api/user";
import mine from "./tabBar/mine.vue";
import shoppingCart from "./tabBar/shoppingCart.vue";
import index from "./index/index.vue";
const umengPush = app.requireModule("eeui/umengPush");
import {count} from "../api/cart";
var globalEvent = app.requireModule('globalEvent');
export default {
  name: 'index-index',
  pageMessage: function (data) {
//    console.log('接收到的信息：', data.message);
    var _this = this
    if (data.message.key == 'orderIndex') {
      // _this.getCartCount()
    }
  },
  data() {
    return {
      welfareMoney:'',
      pageId:1,
      pageNum:1,
      pageSize:10,
      scrollTop: '',
      tabPages: [
        {
          title: "服务站",
          selectedIcon:'https://rzico-weex.oss-cn-hangzhou.aliyuncs.com/img/bianmin.png',
          unSelectedIcon: "https://rzico-weex.oss-cn-hangzhou.aliyuncs.com/img/bianmin1.png",
          url: "./tabBar/order.js",
          tabName: "cart",
          params:'1'
        },
        {
          title: "活动",
          selectedIcon: "https://rzico-weex.oss-cn-hangzhou.aliyuncs.com/img/fuli_tab1.png",
          unSelectedIcon: "https://rzico-weex.oss-cn-hangzhou.aliyuncs.com/img/fuli_tab2.png",
          url: "./tabBar/order.js",
          tabName: "action",
          params:'0'
        },
        {
          title: "批发",
          selectedIcon: "https://rzico-weex.oss-cn-hangzhou.aliyuncs.com/img/shangjia.png",
          unSelectedIcon:"https://rzico-weex.oss-cn-hangzhou.aliyuncs.com/img/shangjia2.png",
          url: "./index/index.js",
          tabName: "index"
        },
        // {
        //   title: "购物车",
        //   selectedIcon: "tb-cart",
        //   url: "./tabBar/shoppingCart.js",
        //   tabName: "cart"
        // },
        {
          title: "测试机",
          selectedIcon:'https://rzico-weex.oss-cn-hangzhou.aliyuncs.com/img/quanmin1.png' ,
          unSelectedIcon:"https://rzico-weex.oss-cn-hangzhou.aliyuncs.com/img/quanmin5.png",
          url: "./tabBar/mine.js",
          tabName: "mine"
        }
      ],
      count: 0, //角标数
      privacyType:false
    };
  },


  created() {
    var _this = this
    this.initIconFont()
      this.imeiId = this.getImei()
      eeui.setPageBackPressed(null, () => {
      eeui.confirm({
            title: "温馨提示",
            message: "你确定要退出吗？",
            buttons: ["取消", "确定"]
          },
          result => {
            if (result.status === "click" && result.title === "确定") {
              eeui.goDesktop()
            }
          }
      );
    });
    // _this.getCartCount()
    umengPush.deviceToken()

  },
  mounted() {
    if (!this.isNull(app.config.params)) {
      if (app.config.params.tab == "cart") {
        this.$refs.reflectName.setCurrentItem("cart");
      }
    }
  },
  pageResume: function (data) {
    var _this = this
    storage.getItem('privacyShow', e => {
      if (e.result == "failed") {
        _this.privacyType = true
      }
    })
    // _this.getCartCount()
  },
  components: {},
  methods: {
    userAgreement(){
      if(this.companyName == "便士达"){
        eeui.openWeb('https://www.qmin365.cn/user.html');
      }
      if(this.companyName == "京小东"){
        eeui.openWeb('https://www.qmin365.cn/juser.html');
      }
      if(this.companyName == "测试机"){
        eeui.openWeb('https://www.qmin365.cn/user.html');
      }
    },
    viewCode(str) {
      this.openViewCode(str);
    },
    pageSelected(params) {
      if (params.position + 1 == 3 || params.position + 1 == 4) {
        if (params.position == 3) {
          // console.info('刷新了1')
          eeui.postMessage({
            pageName: '',
            key: 'mine',
          });
        }
        else if (params.position == 2) {
          // console.info('刷新了3')
//          this.checkLogin(()=>{
            eeui.postMessage({
              pageName: '',
              key: 'cart',
            });
//          })
        }
      }
    },

    //判断是否登录
    checkLogin(callback){
      let _this= this
      if(_this.getGlobalData().token == null){
        const eeui = app.requireModule("eeui");
        eeui.openPage({
              url: "root://pages/login/msgLogin.js",
              statusBarType: 'immersion',
              statusBarStyle: false
            },
            function (result) {

            }
      );
      }else{
        if(callback){
          callback()
        }
      }

    },
    loginClick() {
      const eeui = app.requireModule("eeui");
      eeui.openPage({
            url: "root://pages/login/msgLogin.js",
            statusBarType: 'immersion',
            statusBarStyle: false
          },
          function (result) {

          }
      );
    },
    //获取购物车的数量信息
    // getCartCount() {
    //   var _this = this
    //   let globalData = this.getGlobalData();
    //   if (globalData.token == null) {
    //     return
    //   }
    //   let data = {}
    //   data.uuid = globalData.uuid,
    //       count(data).then(
    //           res => {
    //             if (res.data.quantity > 0) {
    //               _this.$refs.reflectName.showMsg('mine', res.data.quantity);
    //             } else {
    //               _this.$refs.reflectName.hideMsg('mine');
    //             }
    //           }
    //       ).catch(error => {
    //       })
    // },

    disagreeClick(){
      eeui.closePage();
    },
    agreeClick(){
      this.privacyType = false
      storage.setItem('privacyShow', true)
    },

      serviceClick(){
          let params = {
              mchId: this.getGlobalData().mchId,
              tagIds: this.serviceId,
              title:'服务协议'
          };
          eeui.openPage({ url: 'root://pages/member/detail/detail.js', params, statusBarType: "immersion",statusBarStyle: false }, result => {
              // console.log('跳转到详情页成功');
          });
      },
      //隐私政策的点击事件
      privacyClick(){
          let params = {
              mchId: this.getGlobalData().mchId,
              tagIds: this.privacyId,
              title:'隐私政策'
          };
          eeui.openPage({ url: 'root://pages/member/detail/detail.js', params, statusBarType: "immersion",statusBarStyle: false }, result => {
              // console.log('跳转到详情页成功');
          });
      },
  }
};
</script>

<style scoped>
body {
  background-color: #e6e6e6;
}

.app {
  flex: 1;
}

.iconr {
  width: 100px;
  height: 100px;
  color: #ffffff;
}

.tabbar {
  width: 750px;
  flex: 1;
}

.page-content {
  width: 750px;
}

.content-text {
  font-size: 24px;
}

.page-navbar {
  width: 750px;
  height: 90px;
}

.page-navbar-title {
  color: #ffffff;
  font-size: 28px;
}

.page-content-image {
  width: 480px;
  height: 480px;
  margin-top: 30px;
  margin-bottom: 30px;
}

.privacyBox{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0,0,0,0.4);
  display: flex;
  justify-content: center;
  align-items: center;
}
.privacyContent{
  width: 650px;
  /* height: 900px; */
  background-color:white ;
  border-radius: 12px;
  display: flex;
  /* align-items: center; */
  padding-bottom: 50px;
}
.privacy_headerTitle{
  font-size: 42px;
  color: #333333;
  font-weight: bold;
  margin-top: 30px;
  text-align: center;
}
.privacy_title{
  font-size: 30px;
  color: #999999;
  padding-left: 30px;
  padding-right: 30px;
  box-sizing: border-box;
}
.privacy_botton{
  width: 650px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding-left: 30px;
  padding-right: 30px;
  box-sizing: border-box;
  margin-top: 30px;
}
.privacy_botton_left{
  width: 280px;
  height: 80px;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(202,250,241,1);
  border-radius: 50px;
}
.privacy_botton_left_title{
  font-size: 22px;
  color: rgba(42,195,185,1);
}
.privacy_botton_right{
  width: 280px;
  height: 80px;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(0,222,189,1);
  border-radius: 50px;
}
.privacy_botton_right_ittle{
  color: white;
  font-size: 22px;
}
</style>
